package com.qingfeng.testandroid12sdkdemo.network.http

import com.qingfeng.basic_lib.net.RetrofitClient
import com.qingfeng.testandroid12sdkdemo.network.api.HomeService

class HomeNetWork {

    private val mService by lazy { RetrofitClient.getInstance().create(HomeService::class.java) }

    suspend fun getBannerData() = mService.getBanner()

    suspend fun getHomeList(page: Int) = mService.getHomeList(page)

    suspend fun getNaviJson() = mService.naviJson()

    suspend fun getProjectList(page: Int, cid: Int) = mService.getProjectList(page, cid)

    suspend fun getPopularWeb() = mService.getPopularWeb()


    companion object {
//        @Volatile
//        private var netWork: HomeNetWork? = null
//
//        fun getInstance() = netWork ?: synchronized(this) {
//            netWork?: HomeNetWork().also { netWork = it }
//        }
        @Volatile
        private var netWork: HomeNetWork? = null

        fun getInstance() = netWork ?: synchronized(this) {
            netWork ?: HomeNetWork().also { netWork = it }
        }

    }

}

